/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package vn.com.fis.portal.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import vn.com.fis.portal.model.VideoUserTransactionEntry;
import vn.com.fis.portal.model.VideoUserTransactionEntryModel;
import vn.com.fis.portal.model.VideoUserTransactionEntrySoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the VideoUserTransactionEntry service. Represents a row in the &quot;TBL_VIDEO_USER_TRANSACTION&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link vn.com.fis.portal.model.VideoUserTransactionEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link VideoUserTransactionEntryImpl}.
 * </p>
 *
 * @author loind
 * @see VideoUserTransactionEntryImpl
 * @see vn.com.fis.portal.model.VideoUserTransactionEntry
 * @see vn.com.fis.portal.model.VideoUserTransactionEntryModel
 * @generated
 */
@JSON(strict = true)
public class VideoUserTransactionEntryModelImpl extends BaseModelImpl<VideoUserTransactionEntry>
	implements VideoUserTransactionEntryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a video user transaction entry model instance should use the {@link vn.com.fis.portal.model.VideoUserTransactionEntry} interface instead.
	 */
	public static final String TABLE_NAME = "TBL_VIDEO_USER_TRANSACTION";
	public static final Object[][] TABLE_COLUMNS = {
			{ "transactionId", Types.BIGINT },
			{ "transactionCode", Types.BIGINT },
			{ "date_", Types.TIMESTAMP },
			{ "videoId", Types.BIGINT },
			{ "userId", Types.BIGINT },
			{ "receiverId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table TBL_VIDEO_USER_TRANSACTION (transactionId LONG not null primary key,transactionCode LONG,date_ DATE null,videoId LONG,userId LONG,receiverId LONG)";
	public static final String TABLE_SQL_DROP = "drop table TBL_VIDEO_USER_TRANSACTION";
	public static final String ORDER_BY_JPQL = " ORDER BY videoUserTransactionEntry.date_ ASC";
	public static final String ORDER_BY_SQL = " ORDER BY TBL_VIDEO_USER_TRANSACTION.date_ ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.vn.com.fis.portal.model.VideoUserTransactionEntry"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.vn.com.fis.portal.model.VideoUserTransactionEntry"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.vn.com.fis.portal.model.VideoUserTransactionEntry"),
			true);
	public static long DATE__COLUMN_BITMASK = 1L;
	public static long RECEIVERID_COLUMN_BITMASK = 2L;
	public static long TRANSACTIONCODE_COLUMN_BITMASK = 4L;
	public static long USERID_COLUMN_BITMASK = 8L;
	public static long VIDEOID_COLUMN_BITMASK = 16L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static VideoUserTransactionEntry toModel(
		VideoUserTransactionEntrySoap soapModel) {
		VideoUserTransactionEntry model = new VideoUserTransactionEntryImpl();

		model.setTransactionId(soapModel.getTransactionId());
		model.setTransactionCode(soapModel.getTransactionCode());
		model.setDate_(soapModel.getDate_());
		model.setVideoId(soapModel.getVideoId());
		model.setUserId(soapModel.getUserId());
		model.setReceiverId(soapModel.getReceiverId());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<VideoUserTransactionEntry> toModels(
		VideoUserTransactionEntrySoap[] soapModels) {
		List<VideoUserTransactionEntry> models = new ArrayList<VideoUserTransactionEntry>(soapModels.length);

		for (VideoUserTransactionEntrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.vn.com.fis.portal.model.VideoUserTransactionEntry"));

	public VideoUserTransactionEntryModelImpl() {
	}

	public long getPrimaryKey() {
		return _transactionId;
	}

	public void setPrimaryKey(long primaryKey) {
		setTransactionId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_transactionId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return VideoUserTransactionEntry.class;
	}

	public String getModelClassName() {
		return VideoUserTransactionEntry.class.getName();
	}

	@JSON
	public long getTransactionId() {
		return _transactionId;
	}

	public void setTransactionId(long transactionId) {
		_transactionId = transactionId;
	}

	@JSON
	public long getTransactionCode() {
		return _transactionCode;
	}

	public void setTransactionCode(long transactionCode) {
		_columnBitmask |= TRANSACTIONCODE_COLUMN_BITMASK;

		if (!_setOriginalTransactionCode) {
			_setOriginalTransactionCode = true;

			_originalTransactionCode = _transactionCode;
		}

		_transactionCode = transactionCode;
	}

	public long getOriginalTransactionCode() {
		return _originalTransactionCode;
	}

	@JSON
	public Date getDate_() {
		return _date_;
	}

	public void setDate_(Date date_) {
		_columnBitmask = -1L;

		if (_originalDate_ == null) {
			_originalDate_ = _date_;
		}

		_date_ = date_;
	}

	public Date getOriginalDate_() {
		return _originalDate_;
	}

	@JSON
	public long getVideoId() {
		return _videoId;
	}

	public void setVideoId(long videoId) {
		_columnBitmask |= VIDEOID_COLUMN_BITMASK;

		if (!_setOriginalVideoId) {
			_setOriginalVideoId = true;

			_originalVideoId = _videoId;
		}

		_videoId = videoId;
	}

	public long getOriginalVideoId() {
		return _originalVideoId;
	}

	@JSON
	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_columnBitmask |= USERID_COLUMN_BITMASK;

		if (!_setOriginalUserId) {
			_setOriginalUserId = true;

			_originalUserId = _userId;
		}

		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public long getOriginalUserId() {
		return _originalUserId;
	}

	@JSON
	public long getReceiverId() {
		return _receiverId;
	}

	public void setReceiverId(long receiverId) {
		_columnBitmask |= RECEIVERID_COLUMN_BITMASK;

		if (!_setOriginalReceiverId) {
			_setOriginalReceiverId = true;

			_originalReceiverId = _receiverId;
		}

		_receiverId = receiverId;
	}

	public long getOriginalReceiverId() {
		return _originalReceiverId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public VideoUserTransactionEntry toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (VideoUserTransactionEntry)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					VideoUserTransactionEntry.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		VideoUserTransactionEntryImpl videoUserTransactionEntryImpl = new VideoUserTransactionEntryImpl();

		videoUserTransactionEntryImpl.setTransactionId(getTransactionId());
		videoUserTransactionEntryImpl.setTransactionCode(getTransactionCode());
		videoUserTransactionEntryImpl.setDate_(getDate_());
		videoUserTransactionEntryImpl.setVideoId(getVideoId());
		videoUserTransactionEntryImpl.setUserId(getUserId());
		videoUserTransactionEntryImpl.setReceiverId(getReceiverId());

		videoUserTransactionEntryImpl.resetOriginalValues();

		return videoUserTransactionEntryImpl;
	}

	public int compareTo(VideoUserTransactionEntry videoUserTransactionEntry) {
		int value = 0;

		value = DateUtil.compareTo(getDate_(),
				videoUserTransactionEntry.getDate_());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		VideoUserTransactionEntry videoUserTransactionEntry = null;

		try {
			videoUserTransactionEntry = (VideoUserTransactionEntry)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = videoUserTransactionEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		VideoUserTransactionEntryModelImpl videoUserTransactionEntryModelImpl = this;

		videoUserTransactionEntryModelImpl._originalTransactionCode = videoUserTransactionEntryModelImpl._transactionCode;

		videoUserTransactionEntryModelImpl._setOriginalTransactionCode = false;

		videoUserTransactionEntryModelImpl._originalDate_ = videoUserTransactionEntryModelImpl._date_;

		videoUserTransactionEntryModelImpl._originalVideoId = videoUserTransactionEntryModelImpl._videoId;

		videoUserTransactionEntryModelImpl._setOriginalVideoId = false;

		videoUserTransactionEntryModelImpl._originalUserId = videoUserTransactionEntryModelImpl._userId;

		videoUserTransactionEntryModelImpl._setOriginalUserId = false;

		videoUserTransactionEntryModelImpl._originalReceiverId = videoUserTransactionEntryModelImpl._receiverId;

		videoUserTransactionEntryModelImpl._setOriginalReceiverId = false;

		videoUserTransactionEntryModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<VideoUserTransactionEntry> toCacheModel() {
		VideoUserTransactionEntryCacheModel videoUserTransactionEntryCacheModel = new VideoUserTransactionEntryCacheModel();

		videoUserTransactionEntryCacheModel.transactionId = getTransactionId();

		videoUserTransactionEntryCacheModel.transactionCode = getTransactionCode();

		Date date_ = getDate_();

		if (date_ != null) {
			videoUserTransactionEntryCacheModel.date_ = date_.getTime();
		}
		else {
			videoUserTransactionEntryCacheModel.date_ = Long.MIN_VALUE;
		}

		videoUserTransactionEntryCacheModel.videoId = getVideoId();

		videoUserTransactionEntryCacheModel.userId = getUserId();

		videoUserTransactionEntryCacheModel.receiverId = getReceiverId();

		return videoUserTransactionEntryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{transactionId=");
		sb.append(getTransactionId());
		sb.append(", transactionCode=");
		sb.append(getTransactionCode());
		sb.append(", date_=");
		sb.append(getDate_());
		sb.append(", videoId=");
		sb.append(getVideoId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", receiverId=");
		sb.append(getReceiverId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(22);

		sb.append("<model><model-name>");
		sb.append("vn.com.fis.portal.model.VideoUserTransactionEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>transactionId</column-name><column-value><![CDATA[");
		sb.append(getTransactionId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>transactionCode</column-name><column-value><![CDATA[");
		sb.append(getTransactionCode());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>date_</column-name><column-value><![CDATA[");
		sb.append(getDate_());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>videoId</column-name><column-value><![CDATA[");
		sb.append(getVideoId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>receiverId</column-name><column-value><![CDATA[");
		sb.append(getReceiverId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = VideoUserTransactionEntry.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			VideoUserTransactionEntry.class
		};
	private long _transactionId;
	private long _transactionCode;
	private long _originalTransactionCode;
	private boolean _setOriginalTransactionCode;
	private Date _date_;
	private Date _originalDate_;
	private long _videoId;
	private long _originalVideoId;
	private boolean _setOriginalVideoId;
	private long _userId;
	private String _userUuid;
	private long _originalUserId;
	private boolean _setOriginalUserId;
	private long _receiverId;
	private long _originalReceiverId;
	private boolean _setOriginalReceiverId;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private VideoUserTransactionEntry _escapedModelProxy;
}